#ifndef RAY_H_
#define RAY_H_

class AABB;
class AABBGrid;
#include <list>
#include <vector>
#include "Vector.h"
#include "Point.h"
#include <iostream>
#include <allegro.h>

class Triangle;

using std::vector;
using std::list;

class Ray
{
public:
	Ray(const Vector& v, const SPoint& p);
	~Ray();
	
	inline const Vector& getVector(void) const { return vec; }
	inline const Vector& getInverseVector(void) const { return invVec; }
	inline const SPoint& getPoint(void) const { return pos; }
	
	inline float getHitDistance(void) const { return hitDistance; }
	inline void setHitDistance(const float hd) { hitDistance = hd; }
	
	inline const Triangle* getHitTriangle(void) const { return hitTriangle; }
	inline void setHitTriangle(const Triangle* ht) { hitTriangle = ht; }
	
	inline SPoint getHitPoint(void) const {
		return pos + vec * hitDistance;
	}
	
//	int hits(const vector<Triangle*>& triangles) const;
protected:
	const Vector vec;
	const Vector invVec;
	const SPoint pos;
	
	float hitDistance; // distance from origin to first hit
	const Triangle* hitTriangle; // first hit triangle
private:
	Ray(const Ray& copy) : vec(copy.vec), invVec(copy.invVec), pos(copy.pos) {}
};

#endif /*RAY_H_*/
